package com.gump.essay.demo.design.gczms;

import java.util.Observable;

/**
 * 被观察者
 *
 * @auther zzc
 * @date 2020/12/9 16:17
 */
public class Blog extends Observable {

    private String title;

    public Blog(String title) {
        this.title = title;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public void comment(Comment comment) {
        System.out.println(comment.getNickname() + "评论了" + comment.getValue() + "文章");

        //设置标识位  changed = true 表示被观察者发生了变化
        setChanged();

        //通知观察者，可以给观察者传递数据
        notifyObservers(comment);
    }
}
